new function () {
    if (!window.CONF) window.CONF = {};
    xui.setLang('cn');
    formartText = function (caption) {
        caption = xui.adjustRes(caption);
        if (caption.length >= 4) {
            caption = caption.length > 4 ? caption.substring(0, 4) : caption;
        } else {
            for (var i = caption.length; i < 4; i++) {
                caption = caption + '&nbsp;&nbsp;';
            }
        }
        return caption;
    };
    getWidgetItem = function (wid) {
        var itemConfig = {};
        xui.each(CONF.widgets, function (item) {
            if (item.id == wid) {
                itemConfig = xui.clone(item);
            }
        });
        return itemConfig;
    };


    getWidgets = function (wid, iconOnly) {
        var wids = [];
        xui.arr.each(wid, function (o) {
            var wds = chaneWidgetConfig(getWidgetItem(o), iconOnly)
            xui.arr.each(wds, function (ows) {
                wids.push(ows);
            });
        });
        return wids;
    };

    chaneAllWidgetConfigs = function (item, iconOnly) {
        var wids = [], signWids = [], sub = [];
        xui.arr.each(item.sub, function (o) {
            if (!o.sub || o.sub.length == 0) {
                signWids.push(o);
            } else {
                sub.push(o);
            }
        });

        if (signWids.length > 0) {
            var ooitem = xui.clone(item);
            ooitem.sub = signWids;
            var wds = chaneWidgetConfig(ooitem, iconOnly)
            xui.arr.each(wds, function (ows) {
                wids.push(ows);
            });
        }


        xui.arr.each(sub, function (o) {
            var wds = chaneWidgetConfig(o, iconOnly)
            xui.arr.each(wds, function (ows) {
                wids.push(ows);
            });
        });

        return wids;
    };


    chaneWidgetConfigs = function (sub, iconOnly) {
        var wids = [];
        xui.arr.each(sub, function (o) {
            var wds = chaneWidgetConfig(o, iconOnly)
            xui.arr.each(wds, function (ows) {
                wids.push(ows);
            });
        });
        return wids;
    };


    chaneWidgetConfig = function (item, iconOnly) {
        var wids = [];
        var comment = item.comment ? item.comment : item.caption;
        if (!comment) {
            comment = item.id;
        }

        var wditem = {
            id: item.id + 'grop',
            color: "#777777",
            groupStyle: "width:80px;  padding 0 0",
            sub: [
                {
                    id: item.id + 'btn',
                    iconFontSize: "3em",
                    caption: formartText(comment),
                    imageClass: item.imageClass
                }
            ]
        };


        var itemsub = [], width = 0;

        xui.arr.each(item.sub, function (o) {
            var itemConfig = xui.clone(o);
            itemConfig.iconFontSize = "1.5em";
            itemConfig.fontSize = "1em";
            itemConfig.boxStyle = "width:110px,text-align:left";

            var comment = o.comment ? o.comment : o.caption;
            if (!comment) {
                comment = o.id;
            }

            itemConfig.caption = formartText(comment);
            if (!itemConfig.tips) {
                if (xui.str.startWith(itemConfig.id, "xui.UI")) {
                    itemConfig.tips = "在当前位置插入" + itemConfig.caption;
                } else {
                    itemConfig.tips = itemConfig.caption;
                }
            }
            if (o.sub && o.sub.length > 0) {
                itemConfig.iconFontSize = '1.5em';
                itemConfig.dropButton = true;
                var subitem = [];
                xui.arr.each(o.sub, function (oitem) {
                    var oitemConfig = xui.clone(oitem);
                    oitemConfig.caption = oitem.comment ? oitem.comment : oitem.caption;
                    subitem.push(oitemConfig)
                })
                itemConfig.sub = subitem;
                itemConfig.fontSize = "1em";
                itemConfig.boxStyle = "width:110px,text-align:left";
                width = width + 35;
            } else {
                width = width + 35;
            }
            itemsub.push(itemConfig);
        });


        if (item.length % 2 != 0) {
            width = width + 35
        }
        width = width + 35
        var items = {
            id: item.id + 'itemgrop',
            groupStyle: "width:" + (width) + "px; border-style: dashed;border-width: 0 1px 0 0;border-color: rgb(171, 171, 171);padding 0 0",
            sub: itemsub
        };

        wids.push(wditem);
        wids.push(items);
        return wids;
    }
    ;


    xui.merge(window.CONF, {
        toolbarItems: [
            {
                id: 'save',
                groupStyle: "width:80px;  padding 0 0",
                sub: [
                    {
                        id: 'save',
                        iconFontSize: "3em",
                        caption: "保存",
                        iconColor: '#777777',
                        imageClass: 'spafont spa-icon-save',
                        tips: '$RAD.tool.save'
                    }
                ]
            },

            {
                id: 'saveall',
                groupStyle: "width:130px; border-style: dashed;border-width: 0 1px 0 0;border-color: rgb(171, 171, 171);padding 0 0",
                sub: [
                    {
                        id: 'saveall',
                        itemStyle: "width:120px",
                        caption: "保存所有",
                        imageClass: 'spafont spa-icon-saveall',
                        tips: '$RAD.tool.saveall'
                    },
                    {
                        id: 'closeall',
                        itemStyle: "width:120px",
                        caption: "关闭所有",
                        imageClass: 'xui-uicmd-close',
                        tips: '$RAD.tool.closeall'
                    }
                ]
            }
            ,


            {
                id: 'setprojectgroup',
                groupStyle: "width:80px; padding 0 0",
                sub: [
                    {
                        id: 'setproject',
                        caption: "工程配置",
                        iconColor: '#777777',
                        iconFontSize: "3em",
                        imageClass: 'spafont spa-icon-settingprj',
                        tips: '$(RAD.menu.Project Setting)'
                    },

                ]
            },

            {
                id: 'project',
                color: "#777777",
                groupStyle: "width:130px; border-style: dashed;border-width: 0 1px 0 0;border-color: rgb(171, 171, 171);margin: 1px",
                sub: [
                    {
                        id: 'newProject',
                        itemStyle: "width:120px", caption: '$(RAD.esdmenu.newProject)', add: ''
                    },
                    {
                        id: 'openProject',
                        itemStyle: "width:120px", caption: '$(RAD.esdmenu.openProject)', add: ''
                    }]
            },

            {
                id: 'releasebutton',
                color: "#777777",
                groupStyle: "width:80px; padding 0 0",
                sub: [
                    {
                        id: 'release',
                        dropButton: true,
                        iconColor: '#777777',
                        iconFontSize: "3em",
                        caption: "发布",
                        imageClass: 'spafont spa-icon-package',
                        tips: '$RAD.menu.release'
                    },
                ]
            }
            ,
            {
                id: 'other',
                color: "#777777",
                groupStyle: "width:300px; padding 0 0",
                value: "version",
                sub: [

                    {
                        id: 'version',
                        caption: "文件版本",
                        imageClass: "xui-icon-bullet",
                        tips: '$RAD.esdmenu.version'
                    },

                    {
                        id: 'theme',
                        caption: "皮肤样式",
                        dropButton: true,
                        imageClass: 'spafont spa-icon-theme',
                        tips: '$RAD.builder.dftThemeTips'
                    },
                    {id: 'ec', dropButton: true, imageClass: 'spafont spa-icon-language', tips: '$RAD.tool.ec'},
                    {id: "openBPD", imageClass: "spafont spa-icon-alignc", "tips": "$(RAD.esdmenu.openBPD)"},
                    {
                        id: "expressionEditor",

                        imageClass: " spafont spa-icon-function",
                        "tips": "$(RAD.esdmenu.expressionEditor)"
                    },
                    {
                        id: 'serviceManager',

                        imageClass: "spafont spa-icon-options",
                        tips: '$RAD.esdmenu.serviceManager'
                    }
                ]
            }],
        tools: [
            {id: 'editorTheme', iconColor: '#777777', caption: '资源管理', imageClass: 'spafont spa-icon-config'},

            {
                id: 'csstool', caption: '图标字体', color: "#777777", imageClass: "spafont spa-icon-c-label",
                sub: [
                    {id: 'localicon', caption: '导入图标', imageClass: "spafont spa-icon-html"},
                    {id: 'iconfont.cn', caption: '阿里站点', imageClass: 'spafont spa-icon-c-video'}

                ]
            },
            {
                id: 'imgtool', iconColor: '#777777', caption: '图片库', image: "spafont spa-icon-c-image",
                sub: [
                    {id: 'imgmanager', caption: '图片维护', imageClass: "spafont spa-icon-rendermode"},
                    {id: 'imgimport', caption: '导入图片', imageClass: "spafont spa-icon-html"}
                ]
            },

            {
                id: 'apiManager',
                iconColor: '#777777',
                add: '',
                caption: '后端服务',
                imageClass: 'spafont spa-icon-options',
                sub: [
                    {id: 'serviceImport', caption: '服务导入', imageClass: 'spafont spa-icon-c-webapi'},
                    {id: 'serviceManager', caption: '服务维护', imageClass: 'spafont spa-icon-icon-bigup'},
                ],


            },

        ],
        //
        // oneStart: [
        //     {
        //         id: 'mangager', add: '', iconColor: '#777777', caption: '数据库', imageClass: "fa fa-database",
        //         sub: [
        //             {id: 'DBProviderList', caption: '数据源', imageClass: "spafont spa-icon-class"},
        //             {id: 'importTable', caption: '导入库表', imageClass: 'spafont spa-icon-options'},
        //             {id: 'SqlConsole', caption: '数据库监控', imageClass: "spafont spa-icon-c-video"},
        //         ]
        //     }, {
        //         id: 'bpm', add: '', caption: '流程仿真', iconColor: '#777777', imageClass: 'spafont spa-icon-options',
        //         sub: [
        //             {id: 'openBPD', caption: '流程定义', imageClass: "spafont spa-icon-designview"},
        //             {id: 'bpmtest', caption: '仿真测试', imageClass: "spafont spa-icon-action"},
        //             {id: 'OneCodeConfig', caption: '运行配置', imageClass: "bpmfont bpmgongzuoliuxitongpeizhi"},
        //
        //         ]
        //     }
        // ],
        //
        //
        // serverConfig: [
        //     {
        //         id: 'server', add: '', caption: '服务器', iconColor: '#777777', imageClass: "spafont spa-icon-alignw",
        //         sub: [
        //
        //             {id: 'RemoteServerList', caption: '远程配置', imageClass: "spafont spa-icon-c-slider"},
        //             {id: 'ProxyHostList', caption: '代理配置', imageClass: "spafont spa-icon-alignw"}
        //
        //         ]
        //     },
        //     {
        //         id: 'releasegroup',
        //         add: '', caption: '服务器', iconColor: '#777777', imageClass: 'spafont spa-icon-debug',
        //         sub: [
        //
        //
        //             {
        //                 id: 'startServer',
        //                 caption: "启动服务",
        //
        //                 type: 'statusButton',
        //                 imageClass: 'spafont spa-icon-debug',
        //                 tips: '$(RAD.esdmenu.startSrver)'
        //             },
        //             {
        //                 id: "stopServer",
        //                 caption: "关闭服务",
        //                 type: 'statusButton',
        //                 imageClass: "xuicon xui-uicmd-location",
        //                 "tips": "$(RAD.esdmenu.stopServer)"
        //             }, {id: 'ESDServerList', caption: '服务配置', imageClass: "spafont spa-icon-coms"}
        //
        //         ]
        //     }, {
        //         id: 'dsm', add: '', caption: '领域后台', color: "#777777", imageClass: "spafont spa-icon-conf",
        //         sub: [
        //             {id: 'OneCodeDsmConfig', caption: '领域配置', imageClass: "spafont spa-icon-c-cssbox"},
        //             {id: 'dsmDesigner', caption: '编辑器', imageClass: "xui-icon-dialog"}
        //         ]
        //     }
        // ]

    });

    xui.merge(window.CONF, {
            chaneWidget: function (conf) {
                return chaneWidgetConfigs(conf);
            },
            SPATomMenu: function () {
                var spaMenu = [

                    {
                        id: 'file', add: '', caption: '$RAD.menu.file',
                        toolbar: CONF.toolbarItems
                    },

                    // {
                    //     id: 'inster', add: '', caption: '$RAD.esdmenu.inster',
                    //     toolbar: getWidgets(['xui.UI.absForm', 'xui.UI.advForm', 'xui.oa'])
                    // },
                    // {
                    //     id: 'layout', add: '', caption: '布局',
                    //     toolbar: chaneAllWidgetConfigs(getWidgetItem('xui.UI.absContainer'))
                    // }
                    // ,

                    {
                        id: 'tools', caption: '$RAD.menu.tools', toolbar: chaneWidgetConfigs(CONF.tools)
                    },
                    //
                    //
                    // {
                    //     id: 'expression', add: '', caption: '切面公式',
                    //     server: {
                    //         baseUrl: "/action/spatoolbar/Formula",
                    //         params: {
                    //             "engineType": 'CUSTOM',
                    //             "currentClassName": SPA['currentClassName']
                    //         },
                    //     }
                    //
                    // },
                    // {
                    //     id: 'gencode', add: '', caption: '出码模板',
                    //
                    //     server: {
                    //         baseUrl: "/action/spatoolbar/GenCode",.
                    //         params: {"engineType": 'CUSTOM'},
                    //     }
                    // },
                    // {
                    //     id: 'oneStart', caption: '快速开始', toolbar: chaneWidgetConfigs(CONF.oneStart)
                    // },
                    // {
                    //     id: 'serverConfig', caption: '服务配置', toolbar: chaneWidgetConfigs(CONF.serverConfig)
                    // }
                    // {
                    //     id: 'domain', add: '', caption: '领域模型',
                    //     server: {
                    //         baseUrl: "/action/spatoolbar/Domain",
                    //         params: {"engineType": 'CUSTOM'},
                    //     }
                    // },
                    //
                    // {
                    //     id: 'view', add: '', caption: '绘图',
                    //     toolbar: getWidgets(['xui.FusionChartsXT.iot', 'xui.svg'])
                    // }, {
                    //     id: 'chaarts', add: '', caption: '统计',
                    //     toolbar: getWidgets(['xui.UI.FusionChartsXT', 'xui.UI.ECharts'])
                    //
                    // }
                    //,
                    {
                        id: 'plugins', add: '', caption: '插件',
                        plugins: {
                            baseUrl: "/action/spatoolbar/getPluginBar",
                            params: {menuType: 'TOP'},
                        }

                    }
                    //
                    // ,
                    // {
                    //     id: 'dsmplugin', add: '', caption: '领域插件',
                    //     plugins: {
                    //         baseUrl: "/action/spatoolbar/getComponentBar",
                    //         params: {menuType: 'COMPONENT'},
                    //     }
                    //
                    // }

                ]
                return spaMenu;
            }
        }
    );


    xui.merge(window.CONF, {
        navBar: [
            {
                "caption": "消息",
                "flagText": "2",
                "id": "msg",
                "imageClass": "xui-uicmd-info"
            }
        ]
    })

    xui.merge(window.CONF, {
        teamBar: [
            {
                "caption": "配置",
                "id": "setproject",
                "imageClass": "xui-uicmd-opt"
            },
            {
                id: 'openProject',
                caption: "切换工程",
                imageClass: "spafont spa-icon-alignw"
            },

            {
                "caption": "退出",
                "id": "logout",
                "imageClass": "xui-icon-smill"
            }
        ]
    })


    xui.merge(window.CONF, {
        projecttool: [{
            id: 'any', sub: [
                {id: 'refresh', imageClass: 'xuicon xui-refresh', caption: '', tips: '$RAD.tool2.refresh'},
                {id: 'del2', imageClass: 'xuicon xui-icon-minus', caption: '', tips: '$RAD.tool2.del2'},
                {
                    id: 'copy2',
                    hidden: true,
                    imageClass: 'spafont spa-icon-copy',
                    caption: '',
                    tips: '$RAD.tool2.copy2'
                },
                {
                    id: 'paste',
                    hidden: true,
                    imageClass: 'spafont spa-icon-paste',
                    caption: '$RAD.esdmenu.paste',
                    tips: '$RAD.esdmenu.paste'
                },

                {
                    id: 'newClass',
                    imageClass: 'xuicon xui-uicmd-add',
                    caption: '',
                    tips: '$RAD.esdmenu.newClass'
                },

                {
                    id: 'newFolder',
                    imageClass: 'fa fa-folder-o',
                    caption: '',
                    tips: '$RAD.esdmenu.newFolder'
                },

                {
                    id: 'upload',
                    imageClass: 'fa fa-file-o',
                    caption: '',
                    tips: '$RAD.esdmenu.upload'
                },

                {
                    id: 'rename',
                    hidden: true,
                    imageClass: 'spafont spa-icon-rename',
                    caption: '',
                    tips: '$RAD.tool2.modify'
                }
            ]
        },
            {
                id: 'editastext',
                hidden: true,
                imageClass: 'spafont spa-icon-astext',
                caption: '',
                tips: '$RAD.tool2.editastext'
            }
        ]
    })

}
;